import React, { useImperativeHandle } from 'react';

export declare interface ForwordRefType {
  init: (n?: number) => void;
  start: () => void;
  end: (e: string) => void;
}

const ForwordRef = React.forwardRef((props, ref) => {
  useImperativeHandle(
    ref,
    () =>
      ({
        init: (e = 10) => {
          console.log(e, 'init');
        },
        start: () => {
          console.log('start');
        },
        end: (e) => {
          console.log(e, 'end');
        },
      } as ForwordRefType)
  );
  return <div>ForwordRef的组件</div>;
});

export default ForwordRef;
